package com.frejoys.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.frejoys.dao.entity.StoreSale;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

public interface StoreSaleMapper extends BaseMapper<StoreSale> {

    // @Insert("insert into j_store_activity_queue (user_id,store_activity_id,order_id,price,type,create_time,status) values (#{userId}, #{storeActivityId}, #{orderId}, #{price}, #{type}, #{createTime}, #{status})")
    // Boolean addQueue(@Param("userId") Long userId, @Param("storeActivityId") Integer storeActivityId, @Param("orderId") Integer orderId, @Param("price") Integer price, @Param("type") Integer type, @Param("createTime") Integer createTime, @Param("status") Integer status);

    @Insert("insert into j_store_sale (user_id,store_id,store_activity_id,order_id,price,rebate_ratio,promotion_ratio,commission_ratio,bank_cash_charges_ratio,rebate_money,promotion_money,commission_money,money,bank_cash_charges_money,y,ym,ymd,create_time) values (#{userId},#{storeId}, #{storeActivityId}, #{orderId}, #{price}, #{rebateRatio}, #{promotionRatio}, #{commissionRatio}, #{bankCashChargesRatio}, #{rebateMoney}, #{promotionMoney}, #{commissionMoney}, #{money}, #{bankCashChargesMoney}, #{y}, #{ym}, #{ymd}, #{createTime})")
    boolean addInfo(@Param("userId") Long userId, @Param("storeId") Integer storeId, @Param("storeActivityId") Integer storeActivityId, @Param("orderId") Integer orderId, @Param("price") BigDecimal price, @Param("rebateRatio") Float rebateRatio, @Param("promotionRatio") Float promotionRatio, @Param("commissionRatio") Float commissionRatio, @Param("bankCashChargesRatio") Float bankCashChargesRatio, @Param("rebateMoney") BigDecimal rebateMoney, @Param("promotionMoney") BigDecimal promotionMoney, @Param("commissionMoney") BigDecimal commissionMoney, @Param("money") BigDecimal money, @Param("bankCashChargesMoney") BigDecimal bankCashChargesMoney, @Param("y") Integer y, @Param("ym") Integer ym, @Param("ymd") Integer ymd, @Param("createTime") Integer createTime);

    //查询商家实收金额
    @Select("SELECT id,money FROM `j_store_sale` where store_id = #{storeId} and create_time >= #{startTime} and create_time <= #{endTime}")
    List<StoreSale> getMonetList(@Param("storeId") Integer storeId,@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
}
